package cn.xydpeng.springframework.test.postprocess;

import cn.xydpeng.springframework.beans.BeansException;
import cn.xydpeng.springframework.beans.factory.config.BeanPostProcessor;
import cn.xydpeng.springframework.test.bean.UserService;

/**
 * @author xydpeng
 * @version v1.0
 * @date: 2022/10/19
 * @description:
 */
public class MyBeanPostProcesser implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if("userService".equals(beanName)){
            UserService userService =(UserService) bean;
            userService.setLocation("替换为--宇宙中心");
        }
        return bean;
    }
}
